using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Stratman.DesktopProcess.Ec2Console
{
    /// <summary>
    /// Allows the user to enter a name for a new keypair that they wish to create.
    /// </summary>
    public partial class CreateKeypairForm : Form
    {
        /// <summary>
        /// Default constructor.
        /// </summary>
        public CreateKeypairForm()
        {
            InitializeComponent();
        }

        /// <summary>
        /// Gets or sets the keypair name entered by the user.
        /// </summary>
        public string KeypairName
        {
            get
            {
                return keypairNameTextBox.Text;
            }

            set
            {
                keypairNameTextBox.Text = value;
            }
        }

        /// <summary>
        /// Event handler for when the OK button is clicked; sets the DialogResult property
        /// appropriately and closes the form.
        /// </summary>
        /// <param name="sender">
        /// Object from which this event originated (the OK button).
        /// </param>
        /// <param name="e">
        /// Arguments associated with the event.
        /// </param>
        private void okButton_Click(object sender, EventArgs e)
        {
            // Make sure that the user entered a keypair name
            if (String.IsNullOrEmpty(keypairNameTextBox.Text))
            {
                MessageBox.Show("You must specify the keypair name.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            DialogResult = DialogResult.OK;
            Close();
        }

        /// <summary>
        /// Event handler for when the cancel button is clicked; sets the DialogResult property
        /// appropriately and closes the form.
        /// </summary>
        /// <param name="sender">
        /// Object from which this event originated (the cancel button).
        /// </param>
        /// <param name="e">
        /// Arguments associated with the event.
        /// </param>
        private void cancelButton_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
            Close();
        }
    }
}